package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductCateService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.AllProductCateRequest;
import com.mall.shopping.dto.AllProductCateResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 列举所有商品种类
 * @author wxy
 * @date 2022-01-20 15:29
 * @version 1.0
 */
@RestController
@RequestMapping("/shopping")
public class CategoriesController {

    @Reference(timeout = 3000,check = false)
    IProductCateService productCateService;

    @Anoymous
    @RequestMapping("/categories")
    public ResponseData categories(AllProductCateRequest request){

       AllProductCateResponse allProductCateResponse = productCateService.getAllProductCate(request);
       if (ShoppingRetCode.SUCCESS.getCode().equals(allProductCateResponse.getCode())){
           return new ResponseUtil().setData(allProductCateResponse.getProductCateDtoList());
       }

        return new ResponseUtil().setErrorMsg(allProductCateResponse.getMsg());

    }
}
